package com.ruoyi.project.mgr.clazz.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.project.mgr.clazz.domain.MgrClazz;
import com.ruoyi.project.mgr.clazz.mapper.MgrClazzMapper;
import com.ruoyi.project.mgr.clazz.service.IMgrClazzService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.text.Convert;

/**
 * 班级Service业务层处理
 * 
 * @author .
 * @date 2020-02-09
 */
@Service
public class MgrClazzServiceImpl implements IMgrClazzService
{
    @Autowired
    private MgrClazzMapper mgrClazzMapper;

    /**
     * 查询班级
     * 
     * @param clazzId 班级ID
     * @return 班级
     */
    @Override
    public MgrClazz selectMgrClazzById(Long clazzId)
    {
        return mgrClazzMapper.selectMgrClazzById(clazzId);
    }

    /**
     * 查询班级列表
     * 
     * @param mgrClazz 班级
     * @return 班级
     */
    @Override
    public List<MgrClazz> selectMgrClazzList(MgrClazz mgrClazz)
    {
        return mgrClazzMapper.selectMgrClazzList(mgrClazz);
    }

    /**
     * 新增班级
     * 
     * @param mgrClazz 班级
     * @return 结果
     */
    @Override
    public int insertMgrClazz(MgrClazz mgrClazz)
    {
        mgrClazz.setCreateTime(DateUtils.getNowDate());
        mgrClazz.setCreateBy(ShiroUtils.getSysUser().getUserName());
        return mgrClazzMapper.insertMgrClazz(mgrClazz);
    }

    /**
     * 修改班级
     * 
     * @param mgrClazz 班级
     * @return 结果
     */
    @Override
    public int updateMgrClazz(MgrClazz mgrClazz)
    {
        mgrClazz.setUpdateTime(DateUtils.getNowDate());
        mgrClazz.setUpdateBy(ShiroUtils.getSysUser().getUserName());
        return mgrClazzMapper.updateMgrClazz(mgrClazz);
    }

    /**
     * 删除班级对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteMgrClazzByIds(String ids)
    {
        return mgrClazzMapper.deleteMgrClazzByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除班级信息
     * 
     * @param clazzId 班级ID
     * @return 结果
     */
    @Override
    public int deleteMgrClazzById(Long clazzId)
    {
        return mgrClazzMapper.deleteMgrClazzById(clazzId);
    }

    @Override
    public List<MgrClazz> selectClazzNotExistByTeacher(Long teacherId) {
        return mgrClazzMapper.selectClazzNotExistByTeacher(teacherId);
    }

    @Override
    public List<MgrClazz> selectClazzByTeacher(Long teacherId) {
        return mgrClazzMapper.selectClazzByTeacher(teacherId);
    }
}
